package org.vectrics.user.web.struts;

import javax.servlet.jsp.JspException;

import org.vectrics.SystemException;
import org.vectrics.common.util.StringUtils;
import org.vectrics.hibernate.ThreadProperties;
import org.vectrics.struts.VectricsActionData;
import org.vectrics.struts.VectricsStrutsAction;

public class ShowGlobalUserPrivilegesEditAction extends VectricsStrutsAction {

	public ShowGlobalUserPrivilegesEditAction() {
		super();
	}

	protected String doExecute(VectricsActionData actionData)
			throws JspException {
		GlobalUserPrivilegesForm form = new GlobalUserPrivilegesForm();
		form.setPersonId(actionData.getRequest().getParameter("personId"));
		if ((form.getPersonId() == null) || (form.getPersonId().trim().length() == 0)) {
			throw new SystemException("Request parameter 'personId' not specified");
		}
		actionData.setForm(form);
		String domainParam = actionData.getRequest().getParameter("domainId");
		if (StringUtils.isNullOrBlank(domainParam)) {
			actionData.getRequest().setAttribute("domainId", ThreadProperties.getDomain().getId().toString());
		} else {
			actionData.getRequest().setAttribute("domainId", domainParam);
		}
		return(VectricsStrutsAction.FORWARD_SUCCESS);
	}
	
	
}
